import { AuthPowerService } from '@app/auth-power';
import { AccountOrPasswordError } from '@app/error/http.error';
import { Injectable, UnauthorizedException } from '@nestjs/common';
import prisma from '@repo/database';

@Injectable()
export class AuthService {
  constructor(
    private readonly authPowerService: AuthPowerService
  ) { }
  async login({ username, password }) {
    // 暂时抛出错误，因为sys_user模型不存在
    throw new UnauthorizedException('用户系统暂不可用');
    // const user = await prisma.sys_user.findUnique({
    //   where: { username }
    // })
    // if (!user || !user.status) {
    //   throw new UnauthorizedException('账号不存在或已被禁用');
    // }

    // // 验证密码
    // if (!this.authPowerService.comparePassword(
    //   password,
    //   user.password!
    // )) {
    //   throw AccountOrPasswordError
    // }
    
    // // 生成令牌
    // const access_token = this.authPowerService.generateToken(user);

    // return {
    //   ...user,
    //   password: '',
    //   access_token
    // };
  }
}
